<?php get_header(); ?>

	<div id="primary">
		<nav role="navigation" class="site-navigation page-navigation">
			<h1 class="assistive-text"><?php _e( 'Menu', 'tsv-bierden' ); ?></h1>
			<div class="assistive-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'tsv-bierden' ); ?>"><?php _e( 'Skip to content', 'tsv-bierden' ); ?></a></div>

			<?php wp_nav_menu( array( 'theme_location' => 'secondary' ) ); ?>
		</nav>
		<?php get_sidebar(); ?>
	</div> <!-- #primary -->
		<div id="secondary" class="site-content">
		<div id="content" role="main">

		<?php if ( have_posts() ) : ?>
			<header class="archive-header">
				<h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'tsv-bierden' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>

			<?php if ( category_description() ) : // Show an optional category description ?>
				<div class="archive-meta"><?php echo category_description(); ?></div>
			<?php endif; ?>
			</header><!-- .archive-header -->
			<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
			<article id="post-<?php the_ID(); ?>" <?php post_class( 'clearfix' ); ?>>
				<?php
					$post_id = get_the_ID();
				?>
				
				<header class="entry-header">
					<h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
				<?php if ( ( has_post_thumbnail( $post_id ) || '' != get_post_meta( $post_id, 'Thumbnail', true ) ) ) { ?>
					<div class="post-thumbnail">
					<?php
						if ( has_post_thumbnail( $post_id ) ) the_post_thumbnail( 'full' );
						else printf( '<img src="%1$s" alt="%2$s" />', esc_url( get_post_meta( $post_id, 'Thumbnail', true ) ), the_title_attribute( array( 'echo' => 0 ) ) );
					?>
					</div> 	<!-- end .post-thumbnail -->
				<?php } ?>
				</header> <!-- .entry-header -->		
				<div class="entry-content">
					<?php the_content(); ?>
				</div> <!-- .entry-content -->
				<footer class="entry-meta">
					<?php wp_link_pages( array('before' => '<p><strong>' . esc_attr__('Pages','tsv-bierden') . ':</strong> ', 'after' => '</p>', 'next_or_number' => 'number') ); ?>
					<?php edit_post_link( __('Edit this page', 'tsv-bierden') ); ?>
				</footer> <!-- .entry-meta -->
			</article> <!-- end .entry-content -->
		
		<?php endwhile; // end of the loop. ?>
		<?php else : ?>
			<article id="post-0" class="post no-results not-found">

			<?php if ( current_user_can( 'edit_posts' ) ) :
				// Show a different message to a logged-in user who can add posts.
			?>
				<header class="entry-header">
					<h1 class="entry-title"><?php _e( 'No posts to display', 'tsv-bierden' ); ?></h1>
				</header>

				<div class="entry-content">
					<p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'tsv-bierden' ), admin_url( 'post-new.php' ) ); ?></p>
				</div><!-- .entry-content -->

			<?php else :
				// Show the default message to everyone else.
			?>
				<header class="entry-header">
					<h1 class="entry-title"><?php _e( 'Nothing Found', 'tsv-bierden' ); ?></h1>
				</header>

				<div class="entry-content">
					<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'tsv-bierden' ); ?></p>
					<?php get_search_form(); ?>
				</div><!-- .entry-content -->
			<?php endif; // end current_user_can() check ?>

			</article><!-- #post-0 -->
		<?php endif; ?>
		</div><!-- #content -->
	</div><!-- #secondary -->
	
<?php get_footer(); ?>